<!--数据字典管理-->
<template>
    <a-form class="modelSearch">
      <a-row>
        <a-col span="8">
          <a-statistic
              title="应签到人数"
              :value="statistic.shouldSignCount"
              :precision="0"
              :value-style="{ color: '#000000' }"
              style="margin-right: 50px;text-align: center"
          >
          </a-statistic>
        </a-col>
        <a-col span="8">
          <a-statistic
              title="已签到人数"
              :value="statistic.signCount"
              :precision="0"
              :value-style="{ color: '#3f8600' }"
              style="margin-right: 50px;text-align: center"
          >
          </a-statistic>
        </a-col>
        <a-col span="8">
          <a-statistic
              title="签到率"
              :value="statistic.signRate"
              :precision="2"
              suffix="%"
              :value-style="{ color: '#3f8600' }"
              style="margin-right: 50px;text-align: center"
          >
          </a-statistic>
        </a-col>
      </a-row>
    </a-form>
</template>

<script>
export default {
  name: 'signStatistic',
  components: {},
  data() {
    return {
      showAddTable: false,
      statistic: {
        shouldSignCount: 0,
        signCount: 0,
        unSignCount: 0,
        signRate: 0
      },
    }
  },props: {

    classTId:{
      type: String,
      required: false
    }
  },
  computed: {},
  filters: {
    filterWord(value, list) {
      for (let i = 0; i < list.length; i++) {
        if (value === list[i].value) {
          return list[i].label
        }
      }
    },
  },
  methods: {

    showModal(opt) {
      this.classTId = opt.recordId
      this.getSignListData(this.classTId)
    },

    closeModal() {
      this.showAddTable = false
      this.statistic = {
        shouldSignCount: 0,
        signCount: 0,
        unSignCount: 0,
        signRate: 0
      }
    },

    /**
     * Function    : delRole
     * Description : 批量删除角色
     * Input       : none
     * Return      : none
     */
    getSignListData(classTId) {
      let _this = this
      _this.showAddTable = true
      this.$store.dispatch('lessonSignCountAct', {classTId: classTId}).then(response => {
        if (response.code === 0) {
          let statistic = response.data
          if (statistic.signCount === 0 || statistic.shouldSignCount === 0) {
            statistic.signRate = 0.00
          }else {
            statistic.signRate = 100.0*statistic.signCount/statistic.shouldSignCount
          }
          _this.statistic = statistic
        } else {
          this.$message.error(response.message)
        }
      })
    },

  },
  created() {
    this.getSignListData(this.classTId)
  },
  mounted() {

  }
}
</script>
